<template>
  <div id="app">
    <div>
      <h3>部署</h3>
    </div>

    <div>
      <table>
        <thead>
          <tr>
            <th class="sorting_asc">流程名称</th>
            <th class="sorting_asc">流程Key</th>
            <th class="sorting_asc">文件路径</th>
            <th class="sorting_asc">状态</th>
            <th class="text-center">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="flow in flowList" :key="flow.aid">
            <td>{{ flow.flowname }}</td>
            <td>{{ flow.flowkey }}</td>
            <td>{{ flow.filepath }}</td>
            <td>{{ flow.state == 0 ? "已部署" : "未部署" }}</td>
            <td>
              <button type="button" @click="deploy(flow.id)">部署</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
export default {
  name: "VseSupplyChainActiviti",

  data() {
    return {
      flowList: [],
    };
  },

  created: function () {
    //调用方法
    this.findAll();
  },

  mounted() {},

  methods: {
    findAll() {
       this.$axios
        .get("http://localhost:8800/flow/findAll").then((result) => {
        console.log("查找成功！！！");
        this.flowList = result.data;
        console.log("展示");
      });
    },
    deploy: function (id) {
      this.$axios
        .put("http://localhost:8800/flow/deployment/" + id)
        .then((result) => {
          if (result.data == 1) {
            alert("部署成功！");
          } else if (result.data == 2) {
            alert("已经部署过！");
          } else {
            alert("部署失败！！");
          }
          this.findAll();
        });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>